<template>
  <div class="g-dialog-panel confirm">
    <div class="g-dialog-title">
      <span>Confirm Mint</span>
      <div class="g-clickable close" @click="close">
        <i class="iconfont icon-close"></i>
      </div>
    </div>
    <div class="content">
      <div class="head">
        <div class="info">
          <div class="token">
            <span>{{ name }}</span>
          </div>
          <div class="tag">
            <span>{{ description }}</span>
          </div>
        </div>
        <div class="icon">
          <img :src="image" />
        </div>
      </div>
      <div class="item price">
        <div class="name">
          <span>Avatar Price</span>
        </div>
        <div class="value">
          <input type="number" v-model="price" class="g-clear-input" />
        </div>
        <div class="symbol">
          <span>BNB</span>
        </div>
      </div>
      <div class="list">
        <div
          class="item"
          v-for="(item, i) in properties"
          :key="i"
          :name="i"
          :value="item"
          :class="{ hide: !item }"
        >
          <div class="name">
            <span>{{ i }}</span>
          </div>
          <div class="value">
            <span>{{ item }}</span>
          </div>
        </div>
      </div>
      <div class="g-clickable button" @click="$emit('confirm', price)">
        <span>Confirm Mint</span>
      </div>
    </div>
  </div>
</template>

<script>
import SwapLabel from "@/components/SwapLabel";
import { mapState } from "vuex";

export default {
  components: {
    SwapLabel,
  },
  props: {
    MetaData: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {
      price: 1,
    };
  },
  computed: {
    ...mapState({
      account: (state) => state.account,
    }),
    properties() {
      return (this.MetaData && this.MetaData.properties) || {};
    },
    name() {
      return (this.MetaData && this.MetaData.name) || "";
    },
    description() {
      return (this.MetaData && this.MetaData.description) || "";
    },
    image() {
      return (this.MetaData && this.MetaData.image) || "";
    },
  },
  methods: {
    close() {
      this.$emit("close");
    },
  },
};
</script>

<style lang="scss" scoped>
.content {
  padding-top: 40px;
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;

  .info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    .token {
      span {
        font-size: 18px;
        font-family: "Roboto Black";
        color: var(--color);
      }
      margin-bottom: 12px;
    }
    .tag {
      display: flex;
      align-items: center;

      span {
        font-size: 10px;
        font-family: "Roboto Bold";
        line-height: 1.5;
        color: var(--color-content);
      }
    }
  }

  .icon {
    position: relative;
    img {
      width: 64px;
      height: 64px;
      object-fit: cover;
      border-radius: 50%;
    }
  }
}

.list {
  max-height: 160px;
  overflow: auto;
  margin: 0 -30px;
  padding: 0 30px;
}

.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 15px;

  &.price {
    .value {
      flex: 1;
      margin: 0 20px;
      display: flex;
      align-items: center;
      justify-content: flex-end;

      input {
        font-size: 14px;
        color: var(--color);
        font-family: "Roboto Regular";
        background: none;
        text-align: right;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
      }
    }
    .symbol {
      font-size: 14px;
      color: var(--color-content);
      font-family: "Roboto Regular";
    }
  }

  &.hide {
    display: none;
  }

  .name {
    display: flex;
    align-items: center;
    span {
      font-size: 14px;
      color: var(--color-content);
      font-family: "Roboto Regular";
      text-transform: capitalize;
    }
  }

  .value {
    span {
      font-size: 14px;
      color: var(--color);
      font-family: "Roboto Bold";
      text-transform: capitalize;
    }
  }
}

.button {
  height: 60px;
  font-size: 18px;
  color: var(--color-dark);
  background-image: var(--button-bg);
  transition: all 0.3s ease;
  border-radius: 30px;
  margin-top: 30px;

  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;

  span {
    font-size: 15px;
    font-family: "Roboto Bold";
    color: var(--color-dark);
  }
}
</style>
